<template>
  <div class="elm-edit notice_edit">
    <elm-page-bb>
        <el-form ref="model" :model="model" size="small" label-width="80px">
            <elm-row>
                <el-form-item label="标题" prop="title" :rules="[{ required: true, message: '标题必须填写'}]">
                    <el-input v-model="model.title"></el-input>
                </el-form-item>
            </elm-row>
            <elm-row>
                <el-form-item label="作者" prop="author" :rules="[{ required: true, message: '作者必须填写'}]">
                    <el-input v-model="model.author"></el-input>
                </el-form-item>
                <el-form-item label="发布时间" prop="publish_time" :rules="[{ required: true, message: '时间必须选择'}]">
                  <el-date-picker v-model="model.publish_time" type="datetime" value-format="yyyy-MM-ddTHH:mm:ss"
                                  style="width: 100%">
                  </el-date-picker>
                </el-form-item>
            </elm-row>
            <elm-row>
                <el-form-item label="内容" prop="content" style="width: 100%">
                  <elm-ckeditor :rel-id="model.id" v-model="model.content">
                  </elm-ckeditor>
                </el-form-item>
            </elm-row>
        </el-form>
      <el-card style="margin-top:10px">
        <div slot="header">
          <span>附件</span>
          <elm-upload style="float: right; margin-top:-3px" module_name="biz_cms_notice_files" :rel_id="model.id" :multiple="true" :limit="10"  list-type="file" tip=" "></elm-upload>
        </div>
      </el-card>
        <template #bottom>
            <el-button type="success" size="small" @click="submit" model.>立即保存</el-button>
            <el-button size="small" @click="close">取消</el-button>
        </template>
    </elm-page-bb>
  </div>
</template>

<script>
export default {
    extends: elmVueBase,
    data() {
        return {
            model: {id: elm.newGuid(),views:0},
        }
    },
    created() {
    },
    methods: {
        async submit() {
            await this.$refs["model"].validate();
            var res = await elm.post('/business/cms/notice/Upsert', this.model);
            if (res == true) {
                this.close();
                this.v('保存成功。');
                this.request.callVue.tablebinding();
            } else {
                this.error('保存失败，请稍后尝试。');
            }
        }
    }
}
</script>

<style>
.notice_edit .el-upload-list
{
  position: absolute;
  left: 3px;
  right: 1px;
  bottom: 3px;
  top: 40px;
  overflow: auto;
}
.notice_edit .el-card
{
  position: relative;
  min-height: 150px;
}
.notice_edit .el-upload__tip
{
  display: none;
}
</style>